package com.paradise.sharding.eth.controller;


import com.paradise.sharding.eth.entity.TEthBlock;
import com.paradise.sharding.eth.service.TEthBlockServiceImpl;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * ETH区块表 前端控制器
 * </p>
 *
 * @author Paradise
 * @since 2021-07-12
 */
@Api(tags = "block")
@RestController
@RequestMapping("/eth/block")
@AllArgsConstructor
public class TEthBlockController {

    private final TEthBlockServiceImpl blockService;

    @GetMapping
    public List<TEthBlock> ethBlockList() {
        return blockService.list();
    }

    @GetMapping("/s")
    public TEthBlock ethBlockList(@RequestParam Long number) {
        return blockService.lambdaQuery().eq(TEthBlock::getNumber, number).one();
    }

    @PutMapping
    public boolean insert(@RequestBody TEthBlock block) {
        blockService.save(block);
        return true;
    }

}

